home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / objeas3a / demos / guidemo.cpp < prev    next >
C/C++ Source or Header  |  1994-05-18  |  23KB  |  964 lines

  1. //**************************************************************************
  2. //      This is a demo program to show how to use some of the features of
  3. //      the GUI libraries of the ObjectEase package. To compile and run this
  4. //      demo create a project file including the files GUI30.LIB
  5. //      (use GUI40.LIB if you are using Borland C++ 4.0) and GUIDEMO.CPP.
  6. //      Make sure that the files are located where the project says they are.
  7. //      You may also need to change to path to the GUI.H file in the #includes
  8. //      portion of this file.
  9. //
  10. //      Also note that the following files MUST be in the same directory as
  11. //      The executable for this program to operate properly:
  12. //
  13. //              B1.BTN
  14. //              B2.BTN
  15. //              I1.ICN
  16. //              I2.ICN
  17. //              I3.ICN
  18. //
  19. //      BE SURE YOU ARE COMPILING FOR THE LARGE MEMORY MODEL!!!
  20. //**************************************************************************
  21.  
  22. #include "d:\gui\gui.h"
  23. #include <conio.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <graphics.h>
  27.  
  28. #define BKG     3
  29.  
  30. //*************************  FUNCTION PROTOTYPES  **************************
  31.  
  32. void initgraphicdemo();
  33. void gbuttondemo();
  34. void graphbuttondemo();
  35. void paneldemo();
  36. void icondemo();
  37. void acticondemo();
  38. void gmenudemo();
  39. void inputdemo();
  40. void mcursordemo();
  41. void check_radio_demo();
  42. void bitmapdemo();
  43. void pcxdemo();
  44. void scrollbardemo();
  45. void windowdemo();
  46. void dirboxdemo();
  47.  
  48. void write3d(int,char *);
  49. void early_exit();
  50. void norm_exit();
  51. void do_siren();
  52. void do_tele();
  53.  
  54. //***************************  GLOBAL VARIABLES  ***************************
  55.  
  56. extern Mcursor the_mouse;
  57. Screen screen;
  58. int mouse_present=0;
  59. char ch;
  60.  
  61. //**************************************************************************
  62. //              MAIN
  63.  //**************************************************************************
  64.  
  65. void main()
  66. {
  67.     if(farcoreleft()<=350000) {
  68.         puts("This demo requires a minimum of 350K free memory");
  69.         exit(0);
  70.         }
  71.     initgraphicdemo();
  72.     closegraph();
  73.     puts("Thank you for previewing the ObjectEase library from");
  74.     puts("David S. Reinhart Associates");
  75.     puts("\n");
  76.     puts("Be sure to check out the code for WORKSHOP.EXE for further reference!");
  77.     exit(0);
  78. }
  79.  
  80. //**************************************************************************
  81. //**************************************************************************
  82. //**************************************************************************
  83.  
  84. void initgraphicdemo()
  85. {
  86.     screen.VGA_480_16();
  87.     delay(1000);
  88.  
  89.     if(!the_mouse.init()) {
  90.         puts("Unable to detect mouse driver. Graphic portion of this demo");
  91.         puts("requires a mouse.");
  92.         closegraph();
  93.         exit(1);
  94.         }
  95.  
  96.     setfillstyle(SOLID_FILL,BKG);
  97.     bar(0,0,getmaxx(),getmaxy());
  98.  
  99.     Bevel mainpanel;
  100.  
  101.     mainpanel.init(50,75,540,125,THICK);
  102.     mainpanel.show();
  103.  
  104.     settextjustify(CENTER_TEXT,TOP_TEXT);
  105.     write3d(100,"ObjectEase graphics demonstration for Borland C++ and");
  106.     write3d(115,"Turbo C++. This demo and the included graphics library file(s)");
  107.     write3d(130,"(c) Copyright 1992-1994, David S. Reinhart Associates");
  108.  
  109.     write3d(160,"Press the <ENTER> key or the right mouse key to progress through");
  110.     write3d(175,"the demo.");
  111.  
  112.     Panel copyrightpanel;
  113.     copyrightpanel.init(3,455,634,21,OUT,THIN);
  114.     copyrightpanel.show();
  115.     setcolor(0);
  116.     write3d(465,"(c) Copyright 1992-1994 - David S. Reinhart Associates");
  117.  
  118.     the_mouse.arm();
  119.  
  120.     int selected=0;
  121.     while(!selected) {
  122.         while(!kbhit() && !the_mouse.RBP());
  123.         if(kbhit()) {
  124.             if((ch=getch())==27)
  125.                 early_exit();
  126.             while(kbhit())getch();
  127.             selected=1;
  128.             }
  129.         if(the_mouse.RBP())
  130.             selected=1;
  131.         }
  132.  
  133.       gbuttondemo();
  134.       graphbuttondemo();
  135.       icondemo();
  136.       acticondemo();
  137.       paneldemo();
  138.       gmenudemo();
  139.       inputdemo();
  140.       mcursordemo();
  141.       check_radio_demo();
  142.       bitmapdemo();
  143.       pcxdemo();
  144.       scrollbardemo();
  145.       windowdemo();
  146.       dirboxdemo();
  147. }
  148.  
  149. //**************************************************************************
  150.  
  151. void mcursordemo()
  152. {
  153.     int cur=1;
  154.  
  155.     the_mouse.hide();
  156.     setfillstyle(SOLID_FILL,3);
  157.     bar(0,0,getmaxx(),getmaxy()-30);
  158.  
  159.     write3d(20,"Press the left mouse key to cycle through cursors.");
  160.     write3d(35,"Press right mouse key to end.");
  161.  
  162.     the_mouse.show();
  163.     while(!the_mouse.RBP()) {
  164.         if(the_mouse.LBP()) {
  165.             cur++;
  166.             if(cur>16)cur=1;
  167.             the_mouse.changeto(cur);
  168.             while(the_mouse.LBP());
  169.             }
  170.         }
  171. }
  172.  
  173. //**************************************************************************
  174.  
  175. void gbuttondemo()
  176. {
  177.     setfillstyle(SOLID_FILL,BKG);
  178.     the_mouse.hide();
  179.     bar(0,0,getmaxx(),getmaxy()-40);
  180.  
  181.     Bevel mainpanel;
  182.     mainpanel.init(30,70,580,230,THICK);
  183.     mainpanel.show();
  184.  
  185.     write3d(85,"Buttons are one of the most fundamental graphic objects.");
  186.     write3d(100,"They are very popular within graphics environments");
  187.     write3d(115,"for getting user input. You, the programmer, have complete");
  188.     write3d(130,"control over how these button objects function. That is");
  189.     write3d(145,"to say, whether the resulting action takes place when the");
  190.     write3d(160,"button is pressed or released; how long the button remains");
  191.     write3d(175,"depressed; etc...  Experiment with the buttons below.");
  192.  
  193.     Button lowbutton;
  194.     Button medbutton;
  195.     Button hibutton;
  196.     Panel buttonpanel;
  197.  
  198.     lowbutton.init(150,230,"LOW",TEXT);
  199.     medbutton.init(300,230,"MED",TEXT);
  200.     hibutton.init(450,230,"HI",TEXT);
  201.     lowbutton.resize(50,30);
  202.     medbutton.resize(50,30);
  203.     hibutton.resize(50,30);
  204.     buttonpanel.init(130,220,390,50,IN,THICK);
  205.     buttonpanel.setpanelcolor(3);
  206.     buttonpanel.show();
  207.  
  208.     lowbutton.show();
  209.     medbutton.show();
  210.     hibutton.show();
  211.  
  212.     the_mouse.show();
  213.     int selected=0;
  214.  
  215.     flushkeys();
  216.     while(!selected) {
  217.         if(the_mouse.LBP()) {
  218.             if(lowbutton.hit()) {
  219.                 lowbutton.press();
  220.                 while(the_mouse.LBP() && lowbutton.hit());
  221.                 lowbutton.show();
  222.                 if(lowbutton.hit()) {
  223.                     sound(220);
  224.                     delay(500);
  225.                     nosound();
  226.                     continue;
  227.                     }
  228.                 }
  229.             if(medbutton.hit()) {
  230.                 medbutton.press();
  231.                 while(the_mouse.LBP() && medbutton.hit());
  232.                 medbutton.show();
  233.                 if(medbutton.hit()) {
  234.                     sound(440);
  235.                     delay(500);
  236.                     nosound();
  237.                     continue;
  238.                     }
  239.                 }
  240.             if(hibutton.hit()) {
  241.                 hibutton.press();
  242.                 while(the_mouse.LBP() && hibutton.hit());
  243.                 hibutton.show();
  244.                 if(hibutton.hit()) {
  245.                     sound(880);
  246.                     delay(500);
  247.                     nosound();
  248.                     continue;
  249.                     }
  250.                 }
  251.             }// end if the_mouse.LBP
  252.         if(the_mouse.RBP()) {
  253.             selected=1;
  254.             }
  255.         if(kbhit()) {
  256.             if((ch=getch())==27)
  257.                 early_exit();
  258.             while(kbhit())getch();
  259.             selected=1;
  260.             }
  261.         }// end while !selected
  262. }
  263.  
  264. //**************************************************************************
  265.  
  266. void graphbuttondemo()
  267. {
  268.     the_mouse.hide();
  269.     setfillstyle(SOLID_FILL,BKG);
  270.     bar(0,0,getmaxx(),getmaxy()-40);
  271.  
  272.     Bevel mainpanel;
  273.     mainpanel.init(50,50,getmaxx()-100,250,THICK);
  274.     mainpanel.show();
  275.  
  276.     write3d(75,"Buttons can have not only text labels, but graphics as well!");
  277.     write3d(90,"Graphics not only make the interface look nicer, but can");
  278.     write3d(105,"also make the button's function more intuitive for the end user.");
  279.     write3d(120,"Try to guess what the outcome will be before trying out each of");
  280.     write3d(135,"the buttons below.");
  281.     write3d(165,"By the way, these graphic buttons are easy to create using the");
  282.     write3d(180,"ICONEDIT program supplied in this package.");
  283.  
  284.     Panel buttonpanel;
  285.     Button sirenbutton;
  286.     Button telebutton;
  287.  
  288.     buttonpanel.init(270,220,100,50,IN,THICK);
  289.     buttonpanel.setpanelcolor(3);
  290.     buttonpanel.show();
  291.     sirenbutton.init(285,235,"b1",1);
  292.     telebutton.init(330,235,"b2",1);
  293.     sirenbutton.show();
  294.     telebutton.show();
  295.     the_mouse.show();
  296.  
  297.     flushkeys();
  298.     int selected=0;
  299.     while(!selected) {
  300.         if(the_mouse.RBP())
  301.             selected=1;
  302.         if(kbhit()) {
  303.             if((ch=getch())==27)
  304.                 early_exit();
  305.             while(kbhit())getch();
  306.             selected=1;
  307.             }
  308.         if(the_mouse.LBP()) {
  309.             if(sirenbutton.hit()) {
  310.                 sirenbutton.press();
  311.                 while(the_mouse.LBP() && sirenbutton.hit());
  312.                 sirenbutton.show();
  313.                 if(sirenbutton.hit()) {
  314.                     do_siren();
  315.                     continue;
  316.                     }
  317.                 }
  318.             if(telebutton.hit()) {
  319.                 telebutton.press();
  320.                 while(the_mouse.LBP() && telebutton.hit());
  321.                 telebutton.show();
  322.                 if(telebutton.hit()) {
  323.                     do_tele();
  324.                     continue;
  325.                     }
  326.                 }
  327.             }
  328.         }
  329. }
  330.  
  331. //**************************************************************************
  332.  
  333. void paneldemo()
  334. {
  335.     the_mouse.hide();
  336.     setfillstyle(SOLID_FILL,BKG);
  337.     bar(0,0,getmaxx(),getmaxy()-40);
  338.  
  339.     Bevel mainpanel;
  340.     mainpanel.init(10,10,getmaxx()-20,70,THICK);
  341.     mainpanel.show();
  342.  
  343.     write3d(25,"Panels offer an attractive way to partition the graphics screen.");
  344.     write3d(40,"Here are some of the different types of panels that can easily");
  345.     write3d(55,"be implemented using the ObjectEase library.");
  346.  
  347.     Panel inthick;
  348.     Panel inthin;
  349.     Panel outthick;
  350.     Panel outthin;
  351.     Bevel thin;
  352.     Bevel thick;
  353.  
  354.     delay(2000);
  355.     write3d(90,"THICK STYLES                               THIN STYLES");
  356.     inthick.init(50,105,200,100,IN,THICK);
  357.     inthick.show();
  358.     inthin.init(390,105,200,100,IN,THIN);
  359.     inthin.show();
  360.     delay(1000);
  361.     outthick.init(50,220,200,100,OUT,THICK);
  362.     outthick.show();
  363.     outthin.init(390,220,200,100,OUT,THIN);
  364.     outthin.show();
  365.     delay(1000);
  366.     thick.init(50,335,200,100,THICK);
  367.     thick.show();
  368.     thin.init(390,335,200,100,THIN);
  369.     thin.show();
  370.  
  371.     the_mouse.show();
  372.     flushkeys();
  373.     while(!kbhit() && !the_mouse.RBP());
  374.     if(kbhit()) {
  375.         if((ch=getch())==27)
  376.             early_exit();
  377.         while(kbhit())getch();
  378.         }
  379. }
  380.  
  381. //**************************************************************************
  382.  
  383. void icondemo()
  384. {
  385.     the_mouse.hide();
  386.     setfillstyle(SOLID_FILL,BKG);
  387.     bar(0,0,getmaxx(),getmaxy()-40);
  388.  
  389.     Bevel mainpanel;
  390.     mainpanel.init(50,50,getmaxx()-100,200,THICK);
  391.     mainpanel.show();
  392.  
  393.     write3d(75,"What paint program would be complete without icons? Icons are");
  394.     write3d(90,"as intuitive to use as buttons, and once again, using the");
  395.     write3d(105,"ICONEDIT program, they are easy for you, the programmer, to");
  396.     write3d(120,"create. Check out the action of the icons below...");
  397.  
  398.     Panel iconpanel;
  399.     Icon drawicon;
  400.     Icon painticon;
  401.  
  402.     iconpanel.init(250,160,getmaxx()-500,50,IN,THICK);
  403.     iconpanel.setpanelcolor(3);
  404.     iconpanel.show();
  405.     drawicon.init(280,170,"i1");
  406.     painticon.init(330,170,"i2");
  407.     drawicon.show();
  408.     painticon.show();
  409.     the_mouse.show();
  410.  
  411.     flushkeys();
  412.     int selected=0;
  413.     while(!selected) {
  414.         if(the_mouse.RBP())
  415.             selected=1;
  416.         if(kbhit()) {
  417.             if((ch=getch())==27)
  418.                 early_exit();
  419.             while(kbhit())getch();
  420.             selected=1;
  421.             }
  422.         if(the_mouse.LBP()) {
  423.             if(painticon.hit()) {
  424.                 if(!painticon.ispressed()) {
  425.                     painticon.choose();
  426.                     drawicon.show();
  427.                     while(the_mouse.LBP());
  428.                     continue;
  429.                     }
  430.                 }
  431.             if(drawicon.hit()) {
  432.                 if(!drawicon.ispressed()) {
  433.                     drawicon.choose();
  434.                     painticon.show();
  435.                     while(the_mouse.LBP());
  436.                     continue;
  437.                     }
  438.                 }
  439.             }
  440.         }
  441. }
  442.  
  443. //**************************************************************************
  444.  
  445. void acticondemo()
  446. {
  447.     the_mouse.hide();
  448.     setfillstyle(SOLID_FILL,BKG);
  449.     bar(0,0,getmaxx(),getmaxy()-40);
  450.  
  451.     Bevel mainpanel;
  452.     mainpanel.init(50,50,getmaxx()-100,300,THICK);
  453.     mainpanel.show();
  454.  
  455.     write3d(75,"Here's a neat graphic feature that you don't see everyday.");
  456.     write3d(90,"Want to really jazz up your interface? Want to make it stand");
  457.     write3d(105,"out in a crowd?! Instead of reversing the image of your icons");
  458.     write3d(120,"when they are selected, make them come to life! Click the icon");
  459.     write3d(135,"below to see what I mean.");
  460.     write3d(165,"And guess what... Right! These icons are also easy to create");
  461.     write3d(180,"using the ICONEDIT program");
  462.  
  463.     Panel iconpanel;
  464.     iconpanel.init(270,230,getmaxx()-(270*2),70,IN,THICK);
  465.     iconpanel.setpanelcolor(3);
  466.     iconpanel.show();
  467.     Acticon aicon;
  468.     aicon.init(305,250,"i3");
  469.     aicon.show(1);
  470.     the_mouse.show();
  471.  
  472.     int selected=0;
  473.     while(!selected) {
  474.         if(the_mouse.RBP())
  475.             selected=1;
  476.         if(kbhit()) {
  477.             if((ch=getch())==27)
  478.                 early_exit();
  479.             while(kbhit())getch();
  480.             selected=1;
  481.             }
  482.         if(the_mouse.LBP()) {
  483.             if(aicon.hit()) {
  484.                 while(!the_mouse.RBP() && !kbhit())
  485.                     aicon.backforth(2);
  486.                 if(kbhit()) {
  487.                     flushkeys();
  488.                     selected=1;
  489.                     }
  490.                 if(the_mouse.RBP())
  491.                     selected=1;
  492.                 }
  493.             }
  494.         }
  495. }
  496.  
  497. //**************************************************************************
  498.  
  499. void gmenudemo()
  500. {
  501.     the_mouse.hide();
  502.     setfillstyle(SOLID_FILL,BKG);
  503.     bar(0,0,getmaxx(),getmaxy()-40);
  504.  
  505.     Bevel mainpanel;
  506.     mainpanel.init(30,250,getmaxx()-60,130,THICK);
  507.     mainpanel.show();
  508.  
  509.     write3d(275,"Do you need to include point and shoot type menu bars in your");
  510.     write3d(290,"applications? No problem! Using the ObjectEase library makes it a snap");
  511.     write3d(305,"for you to include graphic pulldown menus! See for yourself...");
  512.     write3d(320,"Activate the menu with the mouse, or by pressing ALT along with");
  513.     write3d(335,"the underlined letter in the menu title. Navigate the menu with");
  514.     write3d(350,"the mouse or via the keyboard.");
  515.  
  516.     Button _3dbutton;
  517.     _3dbutton.init(0,0,"Make Menu 3D!!!",TEXT);
  518.     _3dbutton.move((getmaxx()/2)-(_3dbutton.Getw()/2),getmaxy()-80);
  519.     _3dbutton.show();
  520.  
  521.     menubar mb;
  522.     pulldown pd1,pd2,pd3,pd4;
  523.  
  524.     pd1.init(0,15,14,1,0,0);
  525.     pd1.set_option(0,"&Open",1);
  526.     pd1.set_option(1,"&Save",2);
  527.     pd1.set_option(2,"Save &As",3);
  528.     pd1.set_option(3,"-",0);
  529.     pd1.set_option(4,"E&xit",4);
  530.     pd1.options[4].self_color(0,15,14,4);
  531.  
  532.     pd2.init(0,15,14,1,0,0);
  533.     pd2.set_option(0,"Cu&t",11);
  534.     pd2.set_option(1,"&Copy",12);
  535.     pd2.set_option(2,"&Paste",13);
  536.  
  537.     pd3.init(0,15,14,1,0,0);
  538.     pd3.set_option(0,"&Red",31);
  539.     pd3.set_option(1,"&Yellow",32);
  540.     pd3.set_option(2,"&Blue",33);
  541.     pd3.set_option(3,"&Green",34);
  542.     pd3.set_option(4,"&Purple",35);
  543.     pd3.options[0].self_color(12,15,12,0);
  544.     pd3.options[1].self_color(14,15,14,0);
  545.     pd3.options[2].self_color(9,15,9,0);
  546.     pd3.options[3].self_color(10,15,10,0);
  547.     pd3.options[4].self_color(13,15,13,0);
  548.  
  549.  
  550.     pd4.init(0,15,14,1,0,0);
  551.     pd4.set_option(0,"&Index",21);
  552.     pd4.set_option(1,"-",0);
  553.     pd4.set_option(2,"&About",22);
  554.  
  555.     mb.init(0,15,14,1);
  556.     mb.set_title(0,"&File",&pd1);
  557.     mb.set_title(1,"&Edit",&pd2);
  558.     mb.set_title(2,"&Colors",&pd3);
  559.     mb.set_title(3,"&Help",&pd4);
  560.  
  561.     mb.display();
  562.  
  563.     int selected=0;
  564.     while(!selected) {
  565.         if(kbhit()) {
  566.             if((ch=getch())==27)
  567.                 early_exit();
  568.             flushkeys();
  569.             selected=1;
  570.             continue;
  571.             }
  572.         if(the_mouse.RBP()) {
  573.             selected=1;
  574.             continue;
  575.             }
  576.         if(the_mouse.LBP()) {
  577.             if(_3dbutton.hit()) {
  578.                 _3dbutton.press();
  579.                 while(the_mouse.LBP() && _3dbutton.hit());
  580.                 _3dbutton.show();
  581.                 mb.make_3d();
  582.                 mb.display();
  583.                 }
  584.             }
  585.         if(mb.triggered())
  586.             mb.trackbar();
  587.         }
  588. }
  589.  
  590. //**************************************************************************
  591.  
  592. void inputdemo()
  593. {
  594.     the_mouse.unarm();
  595.     setfillstyle(SOLID_FILL,BKG);
  596.     bar(0,0,getmaxx(),getmaxy()-40);
  597.  
  598.     Bevel mainpanel;
  599.     mainpanel.init(30,50,getmaxx()-60,150,THICK);
  600.     mainpanel.show();
  601.  
  602.     write3d(75,"Getting text input from a graphic based application used to be");
  603.     write3d(90,"a real hassle... NO MORE! The ObjectEase includes functions for");
  604.     write3d(105,"laying out text input fields, simulating the text cursor, and");
  605.     write3d(120,"handling the text strings input by the user. Now you can");
  606.     write3d(135,"capture graphic text input as easily as in text mode.");
  607.     write3d(150,"Try out the sample dialog below.");
  608.  
  609.     Panel dialogpanel;
  610.     dialogpanel.init(150,250,getmaxx()-300,85,IN,THICK);
  611.     dialogpanel.show();
  612.  
  613.     setcolor(15);
  614.     settextjustify(LEFT_TEXT,TOP_TEXT);
  615.     gprintxy(170,275,"First Name: ");
  616.     gprintxy(170,305,"Last Name:  ");
  617.  
  618.     Gstring fname;
  619.     Gstring lname;
  620.     fname.init(270,279,20,0);
  621.     lname.init(270,309,20,0);
  622.     fname.show();
  623.     lname.show();
  624.  
  625.     the_mouse.arm();
  626.     fname.get_input();
  627.     lname.get_input();
  628.  
  629.     write3d(400,"Press <ENTER> to continue...");
  630.  
  631.     flushkeys();
  632.     while(!the_mouse.RBP() && !kbhit());
  633.     if(kbhit()) {
  634.         if((ch=getch())==27)
  635.             early_exit();
  636.         flushkeys();
  637.         }
  638. }
  639.  
  640. //**************************************************************************
  641.  
  642. void check_radio_demo()
  643. {
  644.     int done=0;
  645.  
  646.     the_mouse.hide();
  647.     setfillstyle(SOLID_FILL,BKG);
  648.     bar(0,0,getmaxx(),getmaxy()-40);
  649.     Bevel title;
  650.     Panel mainpanel;
  651.  
  652.     title.init(10,10,getmaxx()-20,40,THICK);
  653.     title.show();
  654.     write3d(27,"Try out the Gcheckboxes and Gradios in the panel below...");
  655.  
  656.     mainpanel.init(50,80,getmaxx()-100,270,IN,THIN);
  657.     mainpanel.show();
  658.     the_mouse.show();
  659.     the_mouse.changeto(ARROW);
  660.  
  661.     Gcheckbox cb[5];
  662.     Gradio    gr[5];
  663.  
  664.     for(int i=0;i<5;i++) {
  665.         cb[i].init(150,100+(50*i),"Checkbox");
  666.         cb[i].show();
  667.         }
  668.  
  669.     for(i=0;i<5;i++) {
  670.         gr[i].init(400,100+(50*i),"Radio");
  671.         gr[i].show();
  672.         }
  673.  
  674.     flushkeys();
  675.     while(!the_mouse.RBP() && !done) {
  676.         if(kbhit()) {
  677.             char ch;
  678.             if((ch=getch())==13) {
  679.                 done=1;
  680.                 continue;
  681.                 }
  682.             else
  683.                 flushkeys();
  684.             }
  685.  
  686.         if(the_mouse.LBP()) {
  687.             for(i=0;i<5;i++) {
  688.                 if(cb[i].hit()) {
  689.                     if(cb[i].is_checked())
  690.                         cb[i].uncheck();
  691.                     else
  692.                         cb[i].check();
  693.                     while(the_mouse.LBP());
  694.                     }
  695.                 }//for
  696.             for(i=0;i<5;i++) {
  697.                 if(gr[i].hit()) {
  698.                     if(!gr[i].is_checked()) {
  699.                         for(int j=0;j<5;j++) {
  700.                             if(gr[j].is_checked()) {
  701.                                 gr[j].uncheck();
  702.                                 break;
  703.                                 }
  704.                             }
  705.                         gr[i].check();
  706.                         while(the_mouse.LBP());
  707.                         }
  708.                     }
  709.                 }//for
  710.             }//if LBP
  711.         }//WHILE
  712.     while(the_mouse.RBP());
  713. }
  714.  
  715. //**************************************************************************
  716.  
  717. void bitmapdemo()
  718. {
  719.     int lastx,lasty,x,y;
  720.     lastx=lasty=x,y=0;
  721.     int done=0;
  722.  
  723.     the_mouse.unarm();
  724.     setfillstyle(SOLID_FILL,BKG);
  725.     bar(0,0,getmaxx(),getmaxy()-40);
  726.  
  727.     Bevel title;
  728.     title.init(10,10,getmaxx()-20,40,THICK);
  729.     title.show();
  730.     write3d(27,"Click the left mouse button on the ball and drag it around...");
  731.  
  732.     Panel mainpanel;
  733.     mainpanel.init(100,80,getmaxx()-200,200,IN,THIN);
  734.     mainpanel.show();
  735.     setfillstyle(SOLID_FILL,0);
  736.     bar(101,81,538,279);
  737.  
  738.     Bitmap ball;
  739.  
  740.     ball.init(200,150);
  741.     ball.load("c2.cut");
  742.  
  743.     ball.show_COPY();
  744.     the_mouse.arm();
  745.     the_mouse.changeto(HAND);
  746.  
  747.     flushkeys();
  748.     while(!the_mouse.RBP() && !done) {
  749.         if(kbhit()) {
  750.             char ch;
  751.             if((ch=getch())==13) {
  752.                 done=1;
  753.                 continue;
  754.                 }
  755.             }
  756.  
  757.         if(the_mouse.LBP()) {
  758.             the_mouse.set_hor_bounds(121,520);
  759.             the_mouse.set_ver_bounds(101,260);
  760.             if(ball.hit()) {
  761.                 while(the_mouse.LBP()) {
  762.                     x=the_mouse.mx();
  763.                     y=the_mouse.my();
  764.                     if(x!=lastx || y!=lasty) {
  765.                         ball.moveto(x-20,y-20);
  766.                         lastx=x;
  767.                         lasty=y;
  768.                         }
  769.                     }
  770.                 the_mouse.set_hor_bounds(0,getmaxx());
  771.                 the_mouse.set_ver_bounds(0,getmaxy());
  772.                 }
  773.             }
  774.         }
  775.     while(the_mouse.RBP());
  776.     ball.show_XOR();
  777.     the_mouse.changeto(ARROW);
  778. }
  779.  
  780. //**************************************************************************
  781.  
  782. void pcxdemo()
  783. {
  784.     the_mouse.unarm();
  785.     screen.fill(3);
  786.  
  787.     write3d(55,"Include .PCX files in your applications with just a few");
  788.     write3d(70,"lines of code. It's just as easy in 256 color mode as in");
  789.     write3d(85,"16 color mode. You have total control over screen position.");
  790.  
  791.     PCX pcx;
  792.     pcx.init("leaves.pcx",getmaxx()/2-50,getmaxy()/2-50);
  793.     pcx.show(getmaxx()/2-100,getmaxy()/2-100);
  794.     the_mouse.arm();
  795.  
  796.     flushkeys();
  797.     int done=0;
  798.     while(!the_mouse.RBP() && !done) {
  799.         if(kbhit()) {
  800.             char ch;
  801.             if((ch=getch())==13) {
  802.                 done=1;
  803.                 continue;
  804.                 }
  805.             if(ch==27)
  806.                 early_exit();
  807.             }
  808.         }
  809.     the_mouse.hide();
  810.     Palette pal;
  811.     pal.fadeout();
  812.     screen.fill(0);
  813. }
  814.  
  815. //**************************************************************************
  816.  
  817. void scrollbardemo()
  818. {
  819.     the_mouse.unarm();
  820.     screen.fill(3);
  821.  
  822.     Bevel bevel;
  823.     bevel.init(20,50,getmaxx()-40,100,THICK);
  824.     bevel.show();
  825.  
  826.     write3d(70,"Scroll bars provide an efficient means to regulate values");
  827.     write3d(85,"while providing clear visual feedback to the user. You have");
  828.     write3d(100,"complete control over the length, range, and position of the");
  829.     write3d(115,"scroll bar object. The one on this screen will change the");
  830.     write3d(130,"color value in the square from color 0 through color 15.");
  831.  
  832.     scrollbar sb;
  833.     sb.init(50,400,getmaxx()-100,HORIZONTAL,0,15,20);
  834.     sb.show();
  835.  
  836.     setfillstyle(SOLID_FILL,0);
  837.     bar((getmaxx()/2)-40,(getmaxy()/2)-40,(getmaxx()/2)+40,(getmaxy()/2)+40);
  838.     the_mouse.arm();
  839.  
  840.     while(!kbhit() && !the_mouse.RBP()) {
  841.         if(the_mouse.LBP()) {
  842.             if(sb.hit()) {
  843.                 sb.track_scrollbar();
  844.                 if(sb.value_changed()) {
  845.                     setfillstyle(SOLID_FILL,sb.get_value());
  846.                     bar((getmaxx()/2)-40,(getmaxy()/2)-40,(getmaxx()/2)+40,(getmaxy()/2)+40);
  847.                     }
  848.                 }
  849.             }
  850.         }
  851. }
  852.  
  853. //**************************************************************************
  854.  
  855. void windowdemo()
  856. {
  857.     flushkeys();
  858.     while(the_mouse.RBP());
  859.  
  860.     the_mouse.unarm();
  861.     screen.fill(3);
  862.  
  863.     Bevel bevel;
  864.     bevel.init(20,10,getmaxx()-40,100,THICK);
  865.     bevel.show();
  866.  
  867.     write3d(35,"Graphic window functionality is now provided in the Gwindow");
  868.     write3d(50,"class. You can move this window around by dragging from the");
  869.     write3d(65,"title bar, or resize it by dragging from the");
  870.     write3d(80,"lower right corner of the window.");
  871.  
  872.     Gwindow gw;
  873.     gw.init((getmaxx()/2)-55,getmaxy()/2,110,100,0,15,14,1,"ObjectEase");
  874.     gw.show();
  875.     the_mouse.arm();
  876.  
  877.     while(!kbhit() && !the_mouse.RBP()) {
  878.         if(the_mouse.LBP()) {
  879.             if(gw.sizecornerhit())
  880.                 gw.resize();
  881.             if(gw.titlebarhit())
  882.                 gw.move();
  883.             if(gw.closeboxhit()) {
  884.                 beep();
  885.                 Messagebox("This would normally close the window.",MB_OK);
  886.                 }
  887.             }
  888.         }
  889. }
  890.  
  891. //**************************************************************************
  892.  
  893. void dirboxdemo()
  894. {
  895.     the_mouse.unarm();
  896.     screen.fill(3);
  897.  
  898.     Bevel bevel;
  899.     bevel.init(20,10,getmaxx()-40,80,THICK);
  900.     bevel.show();
  901.  
  902.     write3d(35,"Directory box objects make it easy for the users of your");
  903.     write3d(50,"programs to interact with disk files. And what's more,");
  904.     write3d(65,"These objects can be added with less than 10 lines of code!");
  905.  
  906.     the_mouse.arm();
  907.     {
  908.         dirbox db;
  909.         db.trackdir();
  910.     }
  911. }
  912.  
  913. //**************************************************************************
  914.  
  915. void write3d(int y,char *text)
  916. {
  917.     settextjustify(CENTER_TEXT,TOP_TEXT);
  918.     setcolor(0);
  919.     outtextxy(getmaxx()/2,y,text);
  920.     setcolor(15);
  921.     outtextxy((getmaxx()/2)-1,y-1,text);
  922. }
  923.  
  924. //**************************************************************************
  925.  
  926. void do_siren()
  927. {
  928.     int i;
  929.  
  930.     for(i=500;i<1000;i+=7) {
  931.         sound(i);
  932.         delay(12);
  933.         }
  934.     for(i=1000;i>500;i-=7) {
  935.         sound(i);
  936.         delay(12);
  937.         }
  938.     nosound();
  939. }
  940.  
  941. //**************************************************************************
  942.  
  943. void do_tele()
  944. {
  945.     int i;
  946.  
  947.     for(i=0;i<14;i++) {
  948.         sound(440);
  949.         delay(30);
  950.         sound(880);
  951.         delay(30);
  952.         }
  953.     nosound();
  954. }
  955.  
  956. //**************************************************************************
  957.  
  958. void early_exit()
  959. {
  960.     closegraph();
  961.     puts("You have not seen the entire demonstration.");
  962.     exit(0);
  963. }
  964.